/*
 * WarehouseInfo.java
 *
 * $Id: WarehouseInfo.java,v 1.1 2008-03-18 12:58:46 mario Exp $
 */
package org.ceteca.explica.core.traceability.tree;

import java.util.ArrayList;

/**
 * ValueObject with the data of a Warehouse item.
 * <br/>
 * Responsibilities:
 * <ul>
 *  <li>Store the warehouse data.</li>
 * </ul>
 * <br/>
 * @author Mario García García <mario@imagos.es>
 * Copyright (c) 2007 Fundación Centro Tecnolóxico da Carne
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * <br/>
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * <br/>
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
public class WarehouseInfo {
	/** Warehouse code */
	private String codWarehouse;
	/** Warehouse description */
	private String description;
	/** List with all the appccs information during the time the product
	 * has been stored in the warehouse */
	private ArrayList lAppccs;
	
	/**
	 * Default WarehouseInfo constructor.
	 */
	public WarehouseInfo() {
		this.setCodWarehouse(null);
		this.setDescription(null);
	}
	
	/**
	 * WarehouseInfo constructor that initializes the warehouse values.
	 * @param codWarehouse String, warehouse code.
	 * @param description String, warehouse description.
	 */
	public WarehouseInfo(String codWarehouse, String description) {
		this.setCodWarehouse(codWarehouse);
		this.setDescription(description);
	}
	
	/**
	 * Gets the warehouse appccs' list.
	 * @return ArrayList, list of product comments.
	 */
	public ArrayList getLAppccs() {
		return lAppccs;
	}
	/**
	 * Sets up the list of appccs for the warehouse.
	 * @param appccs ArrayList, list of appccs.
	 */
	public void setLAppccs(ArrayList appccs) {
		lAppccs = appccs;
	}
	/**
	 * Adds a new appcc to the warehouse appccs' list.
	 * @param appcc Object, appcc's data to insert.
	 */
	public void addAppcc(Object appcc) {
		if (this.lAppccs == null)
			this.lAppccs = new ArrayList();
		this.lAppccs.add(appcc);
	}

	/**
	 * Gets the warehouse description.
	 * @return String, warehouse description.
	 */
	public String getDescription() {
		return description;
	}
	/**
	 * Sets up the warehouse description.
	 * @param description String, a description.
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	
	/**
	 * Gets the warehouse code.
	 * @return String, warehouse code.
	 */
	public String getCodWarehouse() {
		return codWarehouse;
	}
	/**
	 * Sets up the warehouse code.
	 * @param codWarehouse String, a warehouse code.
	 */
	public void setCodWarehouse(String codWarehouse) {
		this.codWarehouse = codWarehouse;
	}
	
	/**
	 * Converts the warehouse info to a formatted String.
	 * @return String, formatted String with the warehouses's data.
	 */
	public String toString() {
		StringBuffer result = new StringBuffer();
		result.append(this.codWarehouse);
		result.append(":  ");
		result.append(this.description);
		
		return result.toString();
	}
	
	/**
	 * Updates the warehouse data.
	 * @param info WarehouseInfo, new warehouse data.
	 */
	public void update(WarehouseInfo info) {
		this.setCodWarehouse(info.getCodWarehouse());
		this.setDescription(info.getDescription());
	}
	
	/**
	 * Returns tag Id assigned to CVS source file.
	 */
	public static String getRevision() {
		return "$Id: WarehouseInfo.java,v 1.1 2008-03-18 12:58:46 mario Exp $";
	}
}
